/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.algorithms.unions;

/**
 *
 * @author WORKSPOT2
 */
public abstract class AbstractUnionAlgorithm
{

    protected int id[];

    protected AbstractUnionAlgorithm(int numberOfObjects)
    {
        id = new int[numberOfObjects];
        for (int i = 0; i < numberOfObjects; i++)
        {
            id[i] = i;
        }
    }

    public abstract void union(int p, int q);

    public abstract boolean isConnected(int p, int q);

    public String getIdArrayAsString()
    {
        String toPrint = "";
        for (int i = 0; i < id.length; i++)
        {
            toPrint = toPrint + (id[i] + " ");
        }
        return toPrint.trim();
    }

    public void printIdArray()
    {
        String toPrint = getIdArrayAsString();
        System.out.println(toPrint);
    }
}
